package com.lv7.core.util.helper;

import com.lv7.core.exception.BusinessException;

import javax.servlet.http.HttpServletRequest;

/**
 * 断言工具
 * @author Oven
 * @date 2018-3-14 13:44:23
 */
public class AssertUtil {

    /**
     * 判断对象是否为空
     * @param object 对象
     * @param message 提示消息
     */
    public static void isNotNull(Object object, String message) {
        if (ValidateHelper.isNullOrEmpty(object)) throw new BusinessException(message);
    }

    /**
     * 判断请求参数是否为空
     * @param request http请求对象
     * @param key 参数名称
     * @param message 提示消息
     */
    public static void isNotNull(HttpServletRequest request, String key, String message) {
        if (ValidateHelper.isNullOrEmpty(request.getParameter(key))) throw new BusinessException(message);
    }
}
